package com.example.dao;

import cn.hutool.crypto.digest.mac.MacEngine;
import com.example.entity.XueyuanInfo;
import com.example.entity.ZhuanyeInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface ZhuanyeInfoDao extends Mapper<ZhuanyeInfo> {
    @Select("select * from zhuanye_info where name=#{name}")
    ZhuanyeInfo findByName(String name);


    @Select("select * from zhuanye_info")
    List<ZhuanyeInfo> selectAllZhuanye();

    @Update("UPDATE zhuanye_info " +
            "SET name = #{name}, department = #{department}, xueyuanid = #{xueyuanid}" +" "+//这个空格必须加，否则会 报错
            "WHERE id = #{id}")
    void updateById(@Param("id") long id, @Param("name")String name, @Param("department")String department, @Param("xueyuanid") Long xueyuanid);

    @Delete("DELETE FROM zhuanye_info WHERE id = #{id}")
    void deleteById(Long id);

    @Select("select * from zhuanye_info")
    List<ZhuanyeInfo> selectAllTeacher();

    @Select("select * from zhuanye_info where name like concat('%',#{name},'%')")
    List<ZhuanyeInfo> findByNamePage(String name);

    @Select("select  * from zhuanye_info where id = #{id}")
    ZhuanyeInfo selectById(Long id);
}
